package com.dycx.api.rabbitmq.consumer;

import com.alibaba.fastjson.JSON;
import com.dycx.payment.entity.PaymentOrderDO;
import com.dycx.user.service.SellerService;
import com.dycx.user.service.UserService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 支付监听
 */
@Slf4j
@Component
public class PaymentListener {

    private static SellerService sellerService;
    private static UserService userService;

    @Autowired
    public void PaymentListener(SellerService sellerService, UserService userService) {
        PaymentListener.sellerService = sellerService;
        PaymentListener.userService = userService;
    }

//    /**
//     * 监听消息
//     *
//     * @param content
//     * @param channel
//     * @param message
//     * @throws IOException
//     */
//    @RabbitListener(queues = "payment.create.queue", containerFactory = "paymentListenerFactory")
//    public void payment(@Payload String content, Channel channel, Message message) throws IOException {
//        try {
//            log.info("============================================>监听创建支付请求:{}", content);
//            PaymentOrderDO paymentOrderDO = JSON.parseObject(content, PaymentOrderDO.class);
//
//
//        } catch (Exception ex) {
//            log.error("============================================>监听创建支付请求:{}，结果：{}", content, ex.getMessage());
//            ex.printStackTrace();
//        } finally {
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//        }
//    }


}
